﻿using System;

namespace diantou.web.enterprise
{
    /// <summary>
    /// 企业用户考试权限视图
    /// </summary>
    /// <typeparam name="viewType"></typeparam>
    abstract class examPermissionView<viewType> : view<viewType>
        where viewType : examPermissionView<viewType>
    {
        /// <summary>
        /// 考试计数是否有效
        /// </summary>
        private byte isCounter;
        /// <summary>
        /// 考试计数
        /// </summary>
        private diantou.examDataAccess.exam.counter counter;
        /// <summary>
        /// 考试计数
        /// </summary>
        internal diantou.examDataAccess.exam.counter Counter
        {
            get
            {
                if (isCounter == 0)
                {
                    counter = diantou.examDataAccess.tcpCall.exam.getCounter(currentUserId);
                    isCounter = 1;
                }
                return counter;
            }
        }
        /// <summary>
        /// 题目计数是否有效
        /// </summary>
        private byte isQuestionCounter;
        /// <summary>
        /// 题目计数
        /// </summary>
        private diantou.examDataAccess.examQuestion.counter questionCounter;
        /// <summary>
        /// 题目计数
        /// </summary>
        internal diantou.examDataAccess.examQuestion.counter QuestionCounter
        {
            get
            {
                if (isQuestionCounter == 0)
                {
                    questionCounter = diantou.examDataAccess.tcpCall.examQuestion.getCounter(currentUserId);
                    isQuestionCounter = 1;
                }
                return questionCounter;
            }
        }
        /// <summary>
        /// 职位计数是否有效
        /// </summary>
        private byte isJobCounter;
        /// <summary>
        /// 职位计数
        /// </summary>
        private diantou.examDataAccess.enterpriseJob.counter jobCounter;
        /// <summary>
        /// 职位计数
        /// </summary>
        internal diantou.examDataAccess.enterpriseJob.counter JobCounter
        {
            get
            {
                if (isJobCounter == 0)
                {
                    jobCounter = diantou.examDataAccess.tcpCall.enterpriseJob.getCount(currentUserId);
                    isJobCounter = 1;
                }
                return jobCounter;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override bool loadView()
        {
            if (base.loadView())
            {
                if (currentUser.IsEnterprisePermission) return true;
                AjaxResponse(new fastCSharp.code.cSharp.webView.errorPath { ErrorPath = diantou.dataModel.path.pub.EnterpriseLogin });
            }
            return false;
        }
        /// <summary>
        /// 
        /// </summary>
        protected override void clear()
        {
            base.clear();
            isCounter = isQuestionCounter = isJobCounter = 0;
        }
    }
}
